import pygame, sys, math


class Milk():
    def __init__(self, speed = [2,2], size = [100,100], pos = (0,0)):
        self.image = pygame.image.load("Resources/Milk/MILK3.png")
        self.image = pygame.transform.scale(self.image, size)
        self.rect = self.image.get_rect()
        self.speedx = speed[0]
        self.speedy = speed[1]
        self.speed = [self.speedx, self.speedy]
        self.radius = self.rect.width/2
        self.place(pos)
        self.living = True
       
    def place(self, pos):
        self.rect.center = pos
    
    def update(self):
        self.move()
    
    def move(self):
        self.speed = [self.speedx, self.speedy]
        self.rect = self.rect.move(self.speed)
    
    def collideWall(self, width, height):
        if self.rect.left < 0 or self.rect.right > width:
            self.speedx = -self.speedx
        if self.rect.bottom > height:
            self.living = False
            return True
        return False
         
  
          
    def distanceToPoint(self, pt):
        x1 = self.rect.center[0]
        y1 = self.rect.center[1]
        x2 = pt[0]
        y2 = pt[1]
        
        return math.sqrt(((x2-x1)**2)+((y2-y1)**2))
    
    
    
    